<?php

class Service extends Controller {
	function getFirewall($apikey, $org)
	{
		$u = new User();
		$u->where("api_key", $apikey)->get();
		if (count($u->all) > 0)
		{
			$userorgs = $u->org->where("orgname", $org)->get()->all;
			if (count($userorgs) > 0)
			{
				$ruleobjs = new Rule();
				$robjs = $ruleobjs->org->where("orgname", $org)->order_by("position", "desc")->get()->all;
				//print $ruleobjs->all_to_array();
				//print_r($ruleobjs->to_array());
				foreach($robjs as $ruleobj)
					print $ruleobj->rule;
				//print_r($ruleobjs->all_to_array());
				/*foreach($ruleobjs as $ruleobj)
				{
					if (isset($ruleobj->position))
					{
						$line = "-I " . $ruleobj->chain->chain . " " . $ruleobj->position;
					} else {
						
					}
					print $line . "<br/>";
					//print_r($ruleobj->all_to_array());
					//if (isset($ruleobj))
				}*/
			} 
		}
	}
}

?>